#ifndef __SPI_H__
#define __SPI_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "stdio.h"
#include "at32f403a_407.h"

#define SPI_Slave                   SPI1
#define SPI_Slave_CLK               CRM_SPI1_PERIPH_CLOCK
#define SPI_Slave_GPIO              GPIOA
#define SPI_Slave_GPIO_CLK          CRM_GPIOA_PERIPH_CLOCK 
#define SPI_Slave_PIN_NSS           GPIO_PINS_4
#define SPI_Slave_PIN_SCK           GPIO_PINS_5
#define SPI_Slave_PIN_MISO          GPIO_PINS_6
#define SPI_Slave_PIN_MOSI          GPIO_PINS_7
#define SPI_Slave_DMA_CLK            CRM_DMA1_PERIPH_CLOCK
#define SPI_Slave_Rx_DMA_Channel     DMA1_CHANNEL2
#define SPI_Slave_Rx_DMA_FLAG        DMA1_FDT2_FLAG
#define SPI_Slave_Tx_DMA_Channel     DMA1_CHANNEL3
#define SPI_Slave_Tx_DMA_FLAG        DMA1_FDT3_FLAG  
//#define SPI_Slave_DT_Base            0x4001300C


#define CMD_LEN 132
#define MSG_LEN 92



void SPI_Init(void);
void SPI_DMA_Send(void);
extern  uint8_t SPI_Slave_Buffer_Rx[CMD_LEN];
extern  uint8_t SPI_Slave_Buffer_Tx[CMD_LEN];


#ifdef __cplusplus
}
#endif

#endif